package com.dhq.myapp.util.http


import androidx.annotation.NonNull
import com.google.gson.JsonElement
import com.rokid.cxr.client.extend.sync.FileListResponse
import io.reactivex.Observable
import okhttp3.MultipartBody
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.FieldMap
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.QueryMap
import retrofit2.http.Streaming
import retrofit2.http.Url

/**
 * DESC
 * Created by admin on 2017/3/28.
 */
interface ApiService {

    /**
     * get请求 添加参数
     */
    @GET
    fun getReq(
        @Url url: String,
        @QueryMap paramMaps: HashMap<String, String>
    ): Observable<JsonElement>

    /**
     * get请求 添加参数
     */
    @GET
    fun getBiologyListRequest(
        @Url url: String,
        @QueryMap paramMaps: HashMap<String, String>
    ): Observable<JsonElement>

    /**
     * post请求 添加表单参数
     */
    @POST
    @FormUrlEncoded
    fun postReq(
        @Url url: String,
        @FieldMap(encoded = true) paramMaps: HashMap<String, Any>
    ): Observable<JsonElement>

    /**
     * post请求 添加json参数
     */
    @POST
    fun postJsonReq(
        @Url url: String,
        @Body jsonBody: RequestBody
    ): Observable<JsonElement>

    /**
     * post请求上传文件
     */
    @Multipart
    @POST
    fun uploadFileReq(
        @NonNull @Url url: String,
        @Part fileList: List<MultipartBody.Part>
    ): Observable<JsonElement>

    /**
     * post请求 添加表单参数
     */
    @Multipart
    @POST
    fun uploadFileReq(
        @Url url: String,
        @QueryMap paramMaps: HashMap<String, Any>,
        @Part fileList: List<MultipartBody.Part>
    ): Observable<JsonElement>

    /**
     * 下载文件
     */
    @Streaming
    @GET
    fun downLoadFileGetReq(
        @NonNull @Url url: String,
        @QueryMap paramMaps: HashMap<String, Any>
    ): Observable<ResponseBody>

    /**
     * 下载文件
     */
    @Streaming
    @POST
    fun downLoadFilePostReq(
        @NonNull @Url url: String,
        @QueryMap paramMaps: HashMap<String, Any>
    ): Observable<ResponseBody>


    @Multipart
    @POST("/server/openFileList")
    fun getFileList(@Part("filePath") var1: RequestBody): Observable<JsonElement>


}